""" 菜单 """
import requests

from api import ProdApi
from func import format_data, page_point_upload

headers = {
    "user-agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36'
}


def get_menu():
    resp = requests.get('http://www.csrc.gov.cn/getChannelList?channelCode=c103904', headers=headers).json()
    data = [[x['channelName'],
             f"http://www.csrc.gov.cn/jiangsu/c103907/zfxxgk_zdgk.shtml?channelid={x['channelId']}"
             ] for x in resp['results']['children']]
    return data


org_id = 320057
pages = get_menu()
print(pages)
data = format_data(org_id, pages)
print(len(data))
page_point_upload(data)
